package com.lwt.db137.controller;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.lwt.db137.bean.UserRole;
import com.lwt.db137.commen.R;
import com.lwt.db137.service.UserroleService;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author lwt
 * @version 1.0
 * @Description
 * @date 2024/12/24 11:43
 */
@CrossOrigin(origins = "*")
@RestController
public class UserRoleController {
    @Autowired
    private UserroleService  userroleService;
    @PostMapping("deleteUserRole")
    public R deleteUserrole(@RequestBody UserRole userRole){
        UpdateWrapper<UserRole> updateWrapper = new UpdateWrapper<>();
        updateWrapper.setEntity(userRole);
        userroleService.remove(updateWrapper);

        return new R();
    }
    @PostMapping("addUserRole")
    public R addUserrole(@RequestBody UserRole userRole){
        UpdateWrapper<UserRole> updateWrapper = new UpdateWrapper<>();
         updateWrapper.setEntity(userRole);
        userroleService.save(userRole);
        return new R();
    }
}
